package c.m.d.b.exception;

public class CMDBException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    private final CMDBErrorCode errorCode;

    public static enum CMDBErrorCode
    {
        BAD_REQUEST(400), NOT_FOUND(404), GENERIC_FAILURE(500), FORBIDDEN(403), CONFLICT(409);

        private final int errorCode;

        private CMDBErrorCode(int errorCode)
        {
            this.errorCode = errorCode;
        }

        public int errorCode()
        {
            return errorCode;
        }
    }

    public CMDBException(CMDBErrorCode errorCode, String message, Exception exception)
    {
        super(message, exception);
        this.errorCode = errorCode;
    }

    public CMDBException(CMDBErrorCode errorCode, String message)
    {
        this(errorCode, message, null);
    }

    public CMDBException(CMDBErrorCode errorCode)
    {
        this(errorCode, "");
    }

    public CMDBException(String message)
    {
        this(CMDBErrorCode.GENERIC_FAILURE, message);
    }

    public CMDBErrorCode getErrorCode()
    {
        return errorCode;
    }
}
